// Plugin  change TITLE


//設定圖形化選項的陣列

var commandsImages = [ 'Tilte01', 'Tilte02', 'Tilte03', 'Tilte04' ];



//建立標題用的綁定選項

Scene_Title.prototype.createCommandWindow = function() {
    this._commandWindow = new Window_TitleCommand(0, 0);
	this._commandWindow.visible = false;
	this._commandWindow.x = Graphics.width * 2;
    this._commandWindow.y = Graphics.height * 2;

    this._commandWindow.setHandler('newGame',  this.commandNewGame.bind(this));
    this._commandWindow.setHandler('continue', this.commandContinue.bind(this));
    this._commandWindow.setHandler('options',  this.commandOptions.bind(this));
    this._commandWindow.setHandler('quit',  this.commandQuit.bind(this));
    this.addWindow(this._commandWindow);
};

//初始標題選項並呼叫圖形化程序

var Winnie_create = Scene_Title.prototype.create;
Scene_Title.prototype.create = function() {

	Winnie_create.apply(this);
	this.createImageCommands();

};


//設定圖形化程序
Scene_Title.prototype.createImageCommands = function(){
	
	this._imageCommands = new Sprite();
	this._imageCommands.x = Graphics.width / 2 - 65;
	this._imageCommands.y = Graphics.height / 2 + 200;
	this.addChild( this._imageCommands );
	
	
}


//標題畫面即時變動更新
var Winnie_update = Scene_Title.prototype.update;
Scene_Title.prototype.update = function() {

   Winnie_update.apply(this);
   this._imageCommands.bitmap = ImageManager.loadSystem( commandsImages[ this._commandWindow._index ] );

};


//標題畫面的初始化設定

Scene_Title.prototype.start = function() {

    Scene_Base.prototype.start.call(this);
    SceneManager.clearStack();
    this.centerSprite(this._backSprite1);
    this.playTitleMusic();
    this.startFadeIn(this.fadeSpeed(), false);
};


//更新菜單圖片變化
	Scene_Title.prototype.update = function(){

		//將菜單的預設控制選擇載入
		Scene_Base.prototype.update.call(this);

		//控制圖片切換樣式
		switch ( this._commandWindow._index ){

		
			case 0:
				this._newGameButton.bitmap = ImageManager.loadSystem('Tilte01');
				this._continueButton.bitmap = ImageManager.loadSystem('Tilte02o');
				this._optionsButton.bitmap = ImageManager.loadSystem('Tilte03o');
				this._quitButton.bitmap = ImageManager.loadSystem('Tilte04o');
				break;

			case 1:
				this._newGameButton.bitmap = ImageManager.loadSystem('Tilte01o');
				this._continueButton.bitmap = ImageManager.loadSystem('Tilte02');
				this._optionsButton.bitmap = ImageManager.loadSystem('Tilte03o');
				this._quitButton.bitmap = ImageManager.loadSystem('Tilte04o');
				break;
			
			case 2:
				this._newGameButton.bitmap = ImageManager.loadSystem('Tilte01o');
				this._continueButton.bitmap = ImageManager.loadSystem('Tilte02o');
				this._optionsButton.bitmap = ImageManager.loadSystem('Tilte03');
				this._quitButton.bitmap = ImageManager.loadSystem('Tilte04o');
				break;

			case 3:
				this._newGameButton.bitmap = ImageManager.loadSystem('Tilte01o');
				this._continueButton.bitmap = ImageManager.loadSystem('Tilte02o');
				this._optionsButton.bitmap = ImageManager.loadSystem('Tilte03o');
				this._quitButton.bitmap = ImageManager.loadSystem('Tilte04');
				break;

		}

	}

	   Scene_Title.prototype.start = function() {
	   		Scene_Base.prototype.start.call(this);
	};




//建立自訂的選項列表
var Winnie_makeCommandList = Window_TitleCommand.prototype.makeCommandList;
Window_TitleCommand.prototype.makeCommandList = function() {

	Winnie_makeCommandList.apply(this);
	this.addQuitCommand();

}

//設定結束遊戲選項
Window_TitleCommand.prototype.addQuitCommand = function(){

	this.addCommand( 'Quit','quit');

}

//結束遊戲的功能
Scene_Title.prototype.commandQuit = function(){

	SceneManager.exit();

}